#include <stdio.h>
struct salary{
	char name[10];
	float basic;
	float change;
	float disbursement;
	float real;
};
int main()
{
	int n,i;
	scanf("%d",&n);
	struct salary a[n];
	for(i=0;i<n;i++){
		scanf("%s %f %f %f",a[i].name,&a[i].basic,&a[i].change,&a[i].disbursement);
	}
	for(i=0;i<n;i++){
		a[i].real = a[i].basic + a[i].change - a[i].disbursement; 
		
	}
for(i=0;i<n;i++){
printf("%s %.2f\n",a[i].name,a[i].real);}
	return 0;
}
